<?php
$this->AddHook('before_other_work', 'cityfran');
$this->AddHook('download_images', 'cityfran_refreshAfterDBSave');
function cityfran($x0b)
{
   $x3a = "bc\x6d\165\154";
   $x3b = "\x62\143a\144\x64";
   $x3c = "bc\144\x69\x76";
   $x3d = "\142\143\x73\x75\x62";
   $x3e = "\144ate";
   $x3f = "\x65\x78p\x6c\x6f\144\145";
   $x40 = "fc\x6c\x6fs\x65";
   $x41 = "\x66\154\x6f\141t\x76\141l";
   $x42 = "\x66\x6f\x70e\x6e";
   $x43 = "\x66w\162it\x65";
   $x44 = "\x69\156_\141\x72r\141y";
   $x45 = "i\163\137a\162ray";
   $x46 = "is\x5f\x64i\162";
   $x47 = "\x6d\x69\143\162o\164\151me";
   $x48 = "\x6dk\x64ir";
   $x49 = "\162\141\156\144";
   $x4a = "\x73\x65\x72i\141\154i\172\x65";
   $x4b = "s\x6ce\x65\160";
   $x4c = "\x73\164\162tr";
   $x4d = "\x73\x74\x72\x76\x61\x6c";
   if($x0b->firstrun)
   {
      $x0c = "\143\x69\x74yf\x72\x61\x6e";$x0d = "" . cityfran_VERSION;$x0e = "" . cityfran_DATE;$x0b->ld->UpdatePluginVersion($x0b, $x0c, $x0d, $x0e
      );return;
   }$x0f = $x0b->ld->GetPlSettings("\143\x69\x74y\x66\162\141n");$x10 = $x0b->ld->GetPlSettings("\x63\151\164\x79fr\x61n\x4e");if(isset($x0f->cbfcnamerun) && ($x0f->cbfcnamerun
    == true))
   {
      if(isset($x0f->selitems) && isset($x0f->cntsel))
      {
         if($x0f->cntsel > 0)
         {
            $x0b->SendMsg(' ');
            $x0b->SendMsg('cityfran Start');
            $x11 = (array)$x0f->selitems;
            $x12 = $x0f->cntsel;
            $x13 = array();
            $x14 = 0;
            $x15 = array();
            $x16 = array();
            $x17 = array();
            foreach($x11 as $x18=>$x19)
            {
               unset($x17);$x17 = (array)$x19;if(isset($x17) &&  ! empty($x17))
               {
                  list($x1a, $itemfname) = explode('|', $x17['icode']);$x1b = $x17['itype'];$x1c = $x17['ihave'];$x1d = '' . $x18;$x1e = $x10[$x1d];$x1e = $x4c($x1e, '
    ', '_');if($x1c == 'f')                    {if( ! $x44($x1a, $x13))                       {$x13[] = $x17['icode'];$x14++;}}$x16[] = array('ic'=>$x1a, 'nc'=>$x1d, 'nn'=>$x1e, 'nf'=>$itemfname);
               }
            }foreach($x13
             as $icode)
            {
               list($x1f, $ifname) = explode('|', $icode);$x0b->SendMsg('#' . $x14 . ' updateFranchiseName: ' . $x1f . ' (' . $ifname . ')');
               unset($x0b->error_msg);
               $x20 = new AMFObject("");
               $x20->_bodys[0] = new MessageBody();
               $x20->_bodys[0]->_value[0] = $x0b->GetAmfHeader();
               $x20->_bodys[0]->targetURI = 'BaseService.dispatchBatch';
               $x20->_bodys[0]->responseURI = '';
               $x20->_bodys[0]->_value[2] = 0;
               list($x21,$x22) = $x3f("\x20", $x47());
               $x23 = $x3a($x22, '1000.0', 3);
               $x24 = $x3a($x21, '1000.0', 3);
               $x25 = $x3b($x23, $x24, 0);
               $x26 = $x4d($x49(0, 1000));
               $x27 = $x3d($x25, $x26, 3);
               $x28 = $x3c($x27, '1000.0', 3);

               $x20->_bodys[0]->_value[1][0]['stamp'] = $x41($x25);
               $x20->_bodys[0]->_value[1][0]['enqueueTime'] = $x41($x28);
               $x20->_bodys[0]->_value[1][0]['transaction']['canPerform'] = true;
               $x20->_bodys[0]->_value[1][0]['sequence'] = $x0b->GetSequense();
               $x20->_bodys[0]->_value[1][0]['functionName'] = "\106r\141\x6e\x63\x68\151\163\145S\145\x72\166ic\145.\x75p\144\x61\164\x65\106\162\141\x6e\x63his\145\116\x61\x6d\145";
               $x20->_bodys[0]->_value[1][0]['params'][0] = $x1f;
               $x20->_bodys[0]->_value[1][0]['params'][1] = $ifname;
               $x20->_bodys[0]->_value[2] = 0;

               $x29 = new AMFSerializer();
               $x2a = $x29->$x4a($x20);
               $x2b = $x0b->SendRequest($x2a);
               $x0b->CheckServerError($x2b);
               $x0b->Add2Report('updateFranchiseName');
               if(isset($x0b->error_msg)) {$x0b->ReloadConfig();}
               $x14--;
            }
            $x0b->ReloadConfig();
            foreach($x16 as $x2c)
            {
               $x0b->SendMsg('#' . $x12 . ' VisitNeighbor: ' . $x2c['nc'] . '_' . $x2c['nn']);
               $x2d = $x0b->NLoadWorld($x2c['nc'], $x2c['nn']);
               if(isset($x0b->error_msg)){$x0b->ReloadConfig();continue;}
               $x2e = false;
               if($x2d)
               {
                  //$x20 = new AMFObject($x2d);
                  //$x2f = new AMFDeserializer($x20->rawData);
                  //$x2f->deserialize($x20);
                  //$x30 = new MessageBody();
                  //$x30 = $x20->_bodys[0];
                  $x30 = $x2d->_bodys[0];
                  if($x45($x30->_value['data'][1]['data']['world']['objects']))
                  {
                     foreach($x30->_value['data'][1]['data']['world']['objects']
                      as $x31)                      {if($x31['className'] == 'LotSite')                          {$x2e = $x31['id'];break;}}
                  }
               }if($x2e
                === false)                 {$x0b->SendMsg('NoLotFound cannot place');continue;}
               else
               {
                  $x0b->SendMsg('LotFound: id' . $x2e);
               }$x32 = array();$x32['lotId'] = $x2e;$x32['recipientID'] = $x2c['nc'];$x32['orderResourceName'] = $x2c['nf'];$x32['resourceType'] = $x2c['ic'];$x0b->SendMsg('Place
    order: ' . $x32['resourceType'] . ' (' . $x32['orderResourceName'] . ')');unset($x0b->error_msg);$x20 = new
               AMFObject("");$x20->_bodys[0] = new MessageBody();$x20->_bodys[0]->_value[0] = $x0b->GetAmfHeader();$x20->_bodys[0]->targetURI = 'BaseService.dispatchBatch';$x20->_bodys[0]->responseURI = '';$x20->_bodys[0]->_value[2] = 0;list($x21,
               $x22) = $x3f("\x20", $x47());$x23 = $x3a($x22, '1000.0', 3);$x24 = $x3a($x21, '1000.0', 3);$x25 = $x3b($x23, $x24, 0);$x26 = $x4d($x49(0, 1000));$x27 = $x3d($x25, $x26, 3);$x28 = $x3c($x27, '1000.0', 3);$x20->_bodys[0]->_value[1][0]['stamp'] = $x41($x25);$x20->_bodys[0]->_value[1][0]['enqueueTime'] = $x41($x28);$x20->_bodys[0]->_value[1][0]['transaction']['canPerform'] = true;$x20->_bodys[0]->_value[1][0]['sequence'] = $x0b->GetSequense();$x20->_bodys[0]->_value[1][0]['functionName'] = "\x4co\x74O\162d\145\162Se\x72\x76\x69\143\145.pl\x61ceO\162\x64\145\162";$x20->_bodys[0]->_value[1][0]['params'][0]['constructionCount'] = 0;$x20->_bodys[0]->_value[1][0]['params'][0]['offsetY'] = null;$x20->_bodys[0]->_value[1][0]['params'][0]['senderID'] = $x0b->zyUid;$x20->_bodys[0]->_value[1][0]['params'][0]['lotId'] = $x32['lotId'];$x20->_bodys[0]->_value[1][0]['params'][0]['recipientID'] = $x32['recipientID'];$x20->_bodys[0]->_value[1][0]['params'][0]['orderResourceName'] = $x32['orderResourceName'];$x20->_bodys[0]->_value[1][0]['params'][0]['resourceType'] = $x32['resourceType'];$x20->_bodys[0]->_value[1][0]['params'][0]['offsetX'] = null;$x29 = new
               AMFSerializer();$x2a = $x29->$x4a($x20);
               $x2b = $x0b->SendRequest($x2a);
               $x0b->CheckServerError($x2b);
               $x0b->Add2Report('placeOrder');if(isset($x0b->error_msg))                 {$x0b->ReloadConfig();}$x15[] = array('item'=>$x2c['ic'], 'nname'=>$x2c['nn'], 'ncode'=>$x2c['nc']);$x12--;
            }$x0b->ReloadConfig();$x0f->cbfcnamerun = false;unset($x0f->selitems);$x0f->cntsel = 0;$x0b->ld->SavePlSettings("c\151\x74\171f\x72\141\156", $x0f);$x4b(1);date_default_timezone_set('GMT');$x33 = $x3e("Y_m_d_H_i");$x34 = "\114\x69st\x20\x6ff\040\156\145\151\x67hb\157\x72-i\x74e\155
    y\x6f\x75\x20\160\x6ca\x63\x65\x64\040\142y\040\055c\151t\x79\146r\141\x6e\x2d
    p\x6c\x75\147i\x6e\072\n" . "\104\x61\x74\145\124i\x6de\072\x20" . $x3e("\x59
    \x46\x20\152\x2c\x20\x68\x3ai\x20A") . "\x20\107M\124\n" . "\055-\x2d--\x2d\055\x2d\055-\055\x2d\x2d\x2d\x2d\x2d\x2d\x2d\055\x2d--\055\x2d-\x2d\055\055\x2d--\055\x2d\x2d\x2d\055-\x2d\x2d\055\055-\x2d-\055\x2d\055-\x2d\x2d\x2d-\055\x2d\x2d\055\055\n";foreach($x15
             as $x35)
            {
               $x34 .= "\111t\145\x6d\x20\133" . $x35['item'] . "\135\040\160l\x61ced
    \x6f\156\040\156\145i\x67\x68b\157\x72 \133" . $x35['ncode'] . "\040" . $x35['nname'] . "\135\n";
            }$x34 .= "\x2d-\x2d\x2d-\055\055\x2d-\x2d\055\x2d-\x2d\x2d-\055\x2d--\x2d\x2d\055\055-\055\055-\055---\055----\x2d-\055-\055\x2d-\055\x2d-\055\x2d\055\055--\055-\055\055\n";try
            {
               $x36 = 'tmp_dir/cityfran/';if( ! $x46($x36))                 {@$x48($x36, 0777, true);}$x37 = $x36 . 'cL_' . $x33 . '_' . $x0b->zyUid . '_' . $x0b->usern . '.txt';$x38 = $x42($x37,
               'w');$x43($x38, $x34);$x40($x38);
            }catch(Exception$x39)
            {
               $x0b->SendMsg('
    #' . $x12 . '_Write2File tmp_dir ERROR');
            }$x0b->pm->RefreshMePlugin("\x63\151\x74\x79\x66\x72\141n");$x0b->SendMsg('cityfran
    End');$x0b->SendMsg(' ');
         }
      }
   }
}
function cityfran_refreshAfterDBSave($x0b) {$x0b->pm->RefreshMePlugin("\x63\151\164\x79\146\162\141n");}
?>